//
//  CellForClickZhuanTiCell.m
//  SeeTheWorld
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellForClickZhuanTiCell.h"
#import "ModelForClickZTOfArticle.h"
#import "PCH.pch"
#import <UIImageView+WebCache.h>


@interface CellForClickZhuanTiCell ()

@property (nonatomic, retain)UILabel *label;

@end

@implementation CellForClickZhuanTiCell

- (void)dealloc {
    [_label release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubviews];
        
    }
    return self;
    
}

#pragma mark - 创建子视图
- (void)createSubviews {
    
    self.label = [[UILabel alloc] init];
    [self.contentView addSubview:self.label];
    [_label release];
    self.label.numberOfLines = 0;
    self.label.dk_textColorPicker = DKColorWithRGB(0x343434, 0xffffff);
    self.label.font = [UIFont systemFontOfSize:15];
}

/** 赋值 */
- (void)passModel:(ModelForClickZTOfArticle *)model {
    
    self.label.text = model.descrip;
}

#pragma mark - 布局子视图
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.label.frame = CGRectMake(10, 10, WIDTH - 20, [[self class] heightForLabel:self.label.text]);
    
    
}

/** 自适应高度 */
+ (CGFloat)heightForLabel:(NSString *)text {
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(WIDTH - 20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil];
    
    return rect.size.height;
}

+ (CGFloat)heightForCell:(ModelForClickZTOfArticle *)model {
    
    CGFloat height = [CellForClickZhuanTiCell heightForLabel:model.descrip];
    
    return height + 10 + 10;
    
}















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
